package com.demo.redis.list;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.dao.DataAccessException;
import org.springframework.data.redis.connection.RedisConnection;
import org.springframework.data.redis.core.RedisCallback;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

@Component(value = "PushProducer")
public class Producer implements InitializingBean {

    @Autowired
    RedisTemplate redisTemplate;

    @Override
    public void afterPropertiesSet() throws Exception {

        Thread thread = new Thread(new Runnable() {
            @Override
            public void run() {
                Map<String,Object> map = new HashMap<>();
                map.put("code","abc");
                for (int i = 0; i < 30000; i++) {

                    redisTemplate.opsForList().leftPush("redis-list",map);
                }
            }
        });
        thread.start();
    }
}
